/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dkvklocka;

/**
 *
 * @author max.gabrielsson
 */
import gnu.io.SerialPortEvent; 
import java.util.Observable;

import java.util.logging.Level;
import java.util.logging.Logger;

public class DummySerialListener extends Observable implements ISerialListener {

    private String value; 
    public synchronized void close() {
    }


    public void initialize() {
        Thread t = new Thread(){
            public void run() {
                while(true) {
                    try {
                        value = "S|";
                        sendChunk(value);
                        Thread.sleep(3000);
                        value = "T3000|";
                        sendChunk(value);
                        
                        Thread.sleep(200);
                        value = "T3200|";
                        sendChunk(value);
                        Thread.sleep(5000);
                        value = "U|";
                        sendChunk(value);
                        Thread.sleep(2000);
                        value = "D|";
                        sendChunk(value);
                        Thread.sleep(2000);
                            value = "R|";
                            
                        sendChunk(value);
                         Thread.sleep(2000);
                    } catch (InterruptedException ex) {
                        Logger.getLogger(DummySerialListener.class.getName()).log(Level.SEVERE, null, ex);
                    }
        
            }
           }
        };
        
        t.start();
        
        
        
    }
    public synchronized void serialEvent(SerialPortEvent oEvent) {
        
    }

    public void sendChunk(String value) {
          setChanged();
        notifyObservers(value);
    }

    public void setSetting(String value) {
    }

    @Override
    public String getValue() {
        return value;
    }

	
}